////////////////////////////////////////////////////////////////////////////////////////////////////
/// \file		SUi\SUiLblLed.c
/// 		
/// \author		Sylvain Martin
/// \version	1.0
/// \date		02/24/2011
///
/// \brief	Implants the SUiLblLed class
/// 		
/// \section LICENSE
///
/// This program is free software; you can redistribute it and/or
/// modify it under the terms of the GNU General Public License as
/// published by the Free Software Foundation; either version 2 of
/// the License, or (at your option) any later version.
/// 
/// This program is distributed in the hope that it will be useful, but
/// WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
/// General Public License for more details at
/// http://www.gnu.org/copyleft/gpl.html
////////////////////////////////////////////////////////////////////////////////////////////////////

#include "SUiLblLed.h"
#include <QPixmap>
////////////////////////////////////////////////////////////////////////////////////////////////////
/// \fn  SUiLblLed::SUiLblLed( QWidget * parent)
///
/// \brief	Constructor.
///
/// \param parent if not null, the Qt parent.
////////////////////////////////////////////////////////////////////////////////////////////////////
SUiLblLed::SUiLblLed( QWidget * parent /*= NULL*/ ) :QLabel(parent), color_(grey)
{

	setScaledContents (true);
	setColor(grey);
	emit colorChanged(grey);
}

////////////////////////////////////////////////////////////////////////////////////////////////////
/// \fn  void SUiLblLed::setColor( ledColor c )
///
/// \brief	Change the color of the LED
///
/// \param c The chosen color.
////////////////////////////////////////////////////////////////////////////////////////////////////
void SUiLblLed::setColor( ledColor c )
{
	if (c == color_) return;
	
	QString name;

	switch(c){
	case red:
		name = "red";
		break;
	case green:
		name = "green";
		break;
	case grey:
		name = "grey";
		break;
	case yellow:
		name = "yellow";
		break;
	case blue:
		name = "blue";
		break;
	}

	QPixmap pixmap(":/led/circle_" + name);
	this->setPixmap(pixmap);
	color_ = c;
	emit colorChanged(c);
}

////////////////////////////////////////////////////////////////////////////////////////////////////
/// \fn  SUiLblLed::ledColor SUiLblLed::color()
///
/// \brief	Gets the color.
///
////////////////////////////////////////////////////////////////////////////////////////////////////
SUiLblLed::ledColor SUiLblLed::color()
{
	return color_;
}

////////////////////////////////////////////////////////////////////////////////////////////////////
/// \fn  bool SUiLblLed::isRed()
///
/// \brief	Check if the color is red.
///
/// \return True if the color is red, false if it is not.
////////////////////////////////////////////////////////////////////////////////////////////////////
bool SUiLblLed::isRed()
{
	return color_ == red;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// \fn  bool SUiLblLed::isGreen()
///
/// \brief	Check if the color is green.
///
/// \return True if the color is green, false if it is not.
////////////////////////////////////////////////////////////////////////////////////////////////////
bool SUiLblLed::isGreen()
{
	return color_ == green;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// \fn  bool SUiLblLed::isYellow()
///
/// \brief	Check if the color is yellow.
///
/// \return True if the color is yellow, false if it is not.
////////////////////////////////////////////////////////////////////////////////////////////////////
bool SUiLblLed::isYellow()
{
	return color_ == yellow;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// \fn  bool SUiLblLed::isGrey()
///
/// \brief	Check if the color is grey.
///
/// \return True if the color is grey, false if it is not.
////////////////////////////////////////////////////////////////////////////////////////////////////
bool SUiLblLed::isGrey()
{
	return color_ == grey;
}

////////////////////////////////////////////////////////////////////////////////////////////////////
/// \fn  bool SUiLblLed::isBlue()
///
/// \brief	Check if the color is blue.
///
/// \return True if the color is blue, false if it is not.
////////////////////////////////////////////////////////////////////////////////////////////////////
bool SUiLblLed::isBlue()
{
	return color_ == blue;
}